package com.rockcent.service.impl;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.UserMall;
import com.rockcent.mall.lib.domain.UserMerchant;
import com.rockcent.mall.lib.repository.UserMallRepository;
import com.rockcent.service.UserMallSrv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by zhangjh on 2017/5/31.
 */
@Service
public class UserMallSrvImpl implements UserMallSrv {
    @Autowired
    private UserMallRepository userMallRepository;

    /**
     * @param mallId
     * @return
     */
    @Override
    public List<Long> findUserIdByMallIdAndIsSuperAdmin(Long mallId,Whether isSuperAdmin) {
        List<UserMall> result = userMallRepository.findByMallIdAndIsSuperAdmin(mallId,isSuperAdmin);
        List<Long> userIds = result.stream().map(UserMall::getUserId).collect(Collectors.toList());
        return userIds;
    }
}
